package com.letsiot.applications.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.letsiot.applications.entity.SysResources;
import com.letsiot.applications.service.SysResourcesService;

@RestController
@RequestMapping("/resources")
@Validated
public class SysResoucesController {

    @Autowired
    private SysResourcesService sysResourcesService;

    @PostMapping("save")
    public int save(@RequestBody SysResources entity) {
        return sysResourcesService.save(entity);
    }

    @DeleteMapping("delete")
    public int delete(Long resourceId) {
        return sysResourcesService.delete(resourceId);
    }

    @PutMapping("update")
    public int update(@RequestBody SysResources entity) {
        return sysResourcesService.update(entity);
    }

    @GetMapping("findById")
    public SysResources findById(Long resourceId) {
        return sysResourcesService.findById(resourceId);
    }

    @GetMapping("getAll")
    public List<SysResources> getAll() {
        return sysResourcesService.getAll();
    }

    @GetMapping("findBySystemId")
    public List<SysResources> findBySystemId(Long systemId) {
        return sysResourcesService.findBySystemId(systemId);
    }
}
